﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace MovieExplorer
{
   public partial class ItemChooser : Form
   {
      public ItemChooser()
      {
         InitializeComponent();
      }

      public string HeaderText
      {
      	get { return lblHeader.Text; }
      	set { lblHeader.Text = value; }
      }
      
      public string NewSearchText
      {
      	get { return tbSearch.Text; }
      	set { tbSearch.Text = value; }
      }
      
      public void AddItem(int id, string item)
      {
         listItems.Items.Add(id.ToString()+ "|" +item);
      }

      public string GetSelectedItemValue()
      {
         if (listItems.SelectedItems.Count > 0)
         {
            string[] item = listItems.SelectedItems[0].ToString().Split(new string[] { "|" }, StringSplitOptions.RemoveEmptyEntries);

            return item[1];
         }

         return "";
      }

      public int GetSelectedItemID()
      {
         if (listItems.SelectedItems.Count > 0)
         {
            string[] item = listItems.SelectedItems[0].ToString().Split(new string[] { "|" }, StringSplitOptions.RemoveEmptyEntries);

            return int.Parse(item[0]);
         }

         return -1;
      }

      private void listItems_DoubleClick(object sender, EventArgs e)
      {
         DialogResult = DialogResult.OK;
      }
   }
}
